package cn.imvc.app.repositories;

import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import cn.imvc.app.entities.GoodsPrice;

public interface GoodsPriceRepository extends JpaRepository<GoodsPrice, Integer> {
	@Query("from GoodsPrice gp  join gp.priceClass pc where gp.goodsSku.id = ?1 and pc.code = ?2 and  pc.isDisabled = 0")
	GoodsPrice findPriceBySkuIdAndPriceCode(Integer skuId, String priceClassCode);
	@Query("select gp from GoodsPrice gp, PriceClass pc, Dealer d ,DealerLevel dl where d.dealerLevel.id = dl.id and dl.priceClass.id =pc.id and gp.priceClass.id = pc.id  and gp.goodsSku.id = ?1 and d.member.id = ?2 and  pc.isDisabled = 0")
	GoodsPrice findPriceBySkuIdAndMemderId(Integer skuId, Integer memberId);
	
	List<GoodsPrice> findByGoodsSkuId(Integer goodsSkuId);

}
